home *** CD-ROM | disk | FTP | other *** search
/ Aminet 22 / Aminet 22 (1997)(GTI - Schatztruhe)[!][Dec 1997].iso / Aminet / dev / misc / WHDLoaddev.lha / WHDLoad / Src / sources / blitfix_dn_58a6.s next >
Text File  |  1997-08-31  |  2KB  |  86 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    blitfix_dn_58a6.s
  3. ;  :Contents.    routine to fix program that does not correctly wait for
  4. ;        blitter finish
  5. ;        the instruction which writes the "bltsize" register will be
  6. ;        patched with a routine which will wait for blitter finish
  7. ;        after writing "bltsize"
  8. ;  :History.    30.08.97 extracted from Turrican slave
  9. ;  :Requires.    -
  10. ;  :Copyright.    Public Domain
  11. ;  :Language.    68000 Assembler
  12. ;  :Translator.    Barfly V1.131
  13. ;  :To Do.
  14. ;---------------------------------------------------------------------------*
  15. ;
  16. ; this will patch the following instructions:
  17. ;        move.w    d0,($58,a6)
  18. ;        move.w    d1,($58,a6)
  19. ;        move.w    d2,($58,a6)
  20. ;        move.w    d3,($58,a6)
  21. ;        move.w    d4,($58,a6)
  22. ;        move.w    d5,($58,a6)
  23. ;        move.w    d6,($58,a6)
  24. ;        move.w    d7,($58,a6)
  25. ;
  26. ; IN:    A0 = APTR start of memory to patch
  27. ;    A1 = APTR end of memory to patch
  28. ;    A2 = APTR space for patch routine MUST be < $8000 !!!
  29. ; OUT:    D0-D1/A0-A1 destroyed
  30.  
  31. _blitfix_dn_58a6
  32.         movem.l    a2-a4,-(a7)
  33.  
  34.         move.l    a2,d1            ;D1 = jmp table
  35.  
  36.         lea    (.wait_d0),a3
  37.         lea    (.wait_end),a4
  38. .cpy        move.w    (a3)+,(a2)+
  39.         cmp.l    a3,a4
  40.         bne    .cpy
  41.     IFD PATCHCOUNT
  42.         clr.l    (a2)+
  43.         clr.l    (a2)
  44.     ENDC
  45.  
  46. .loop        move.w    (a0)+,d0
  47.         and.w    #$fff8,d0
  48.         cmp.w    #$3d40,d0        ;move.w dx,($58,a6)
  49.         bne    .next
  50.         cmp.w    #$0058,(a0)
  51.         bne    .next
  52.         move.w    -(a0),d0        ;old opcode
  53.         move.w    #$4eb8,(a0)+        ;JSR $XXXX.w
  54.         move.w    d1,(a0)
  55.         and.w    #7,d0            ;register number
  56.     IFD PATCHCOUNT
  57.         addq.b    #1,(-4,a2,d0)
  58.     ENDC
  59.         mulu    #6,d0
  60.         add.w    d0,(a0)+        ;jmp address
  61. .next        cmp.l    a0,a1
  62.         bhs    .loop
  63.  
  64.         movem.l    (a7)+,a2-a4
  65.         rts
  66.  
  67. .wait_d0    move.w    d0,($58,a6)
  68.         bra.b    .wait
  69. .wait_d1    move.w    d1,($58,a6)
  70.         bra.b    .wait
  71. .wait_d2    move.w    d2,($58,a6)
  72.         bra.b    .wait
  73. .wait_d3    move.w    d3,($58,a6)
  74.         bra.b    .wait
  75. .wait_d4    move.w    d4,($58,a6)
  76.         bra.b    .wait
  77. .wait_d5    move.w    d5,($58,a6)
  78.         bra.b    .wait
  79. .wait_d6    move.w    d6,($58,a6)
  80.         bra.b    .wait
  81. .wait_d7    move.w    d7,($58,a6)
  82. .wait        BLITWAIT a6
  83.         rts
  84. .wait_end
  85.  
  86.